﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using Hyt.Core;

namespace Hyt.Web.Mvc
{
    public class HytControllerFactory : DefaultControllerFactory
    {
        public IUnitOfWork UnitOfWork { get; set; }
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null)
            {
                return base.GetControllerInstance(requestContext, null);
            }
            return (IController) UnitOfWork.Get(controllerType);
            //var controller = base.GetControllerInstance(requestContext, controllerType);
            //UnitOfWork.Inject(controller);
            //return controller;
        }
    }
}
